<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //async 函数
        async function fn() {
            //返回一个字符串
            // return '我是你爸爸';
            //返回的结果不是一个Promise类型的对象,反悔的结果就是成功Promise对象
            // return;
            //抛出错误，返回的结果是一个失败的Promise
            // throw new Error("出错");
            //返回的结果如果是一个Promise对象
            return new Promise((resolve, reject) => {
                resolve('成功的数据');
                reject("失败的错误!");
            });
        }

        const res = fn();
        res.then(value => {
            console.log(value);
        }, reason => {
            console.warn(reason);
        });






    </script>


</body>

</html>